package com.pactera.jep.service.yapin.eval.value.controller;

import com.alibaba.fastjson.JSONObject;
import com.pactera.jep.web.entity.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;

import com.pactera.jep.orm.Filter;
import com.pactera.jep.orm.Order;
import com.pactera.jep.orm.Page;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.pactera.jep.web.controller.CrudController;
import org.springframework.web.bind.annotation.*;

import com.pactera.jep.service.yapin.eval.value.model.EvalProcess;
import com.pactera.jep.service.yapin.eval.value.service.EvalProcessService;


/**
 *
 * @Author YouName
 * @Date 2020-7-20 10:27:32
 */
@RestController
@RequestMapping("/evalProcess")
@Api(description = "押品估值流程信息表")
public class EvalProcessController extends CrudController<EvalProcess> {

    @Autowired
    EvalProcessService evalProcessService;

    @GetMapping("/{id}")
    @ApiOperation("查询押品估值流程信息表")
    public Result get(@PathVariable("id") String evalProcessId) {
        return Result.success(evalProcessService.get(evalProcessId));
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除押品估值流程信息表")
    public Result delete(@PathVariable("id") String evalProcessId) {
        return Result.success(evalProcessService.deleteByPrimaryKey(evalProcessId));
    }

    @PostMapping("/save")
    @ApiOperation("插入押品估值流程信息表")
    public Result insert(@RequestBody EvalProcess evalProcess) {
        evalProcessService.insert(evalProcess);
        return Result.success(evalProcess);
    }

    @PostMapping("/update")
    @ApiOperation("更新押品估值流程信息表")
    public Result update(@RequestBody EvalProcess evalProcess) {
        return Result.success(evalProcessService.update(evalProcess));
    }

    /**
     * 为列表页面做数据准备
     */
    @Override
    protected void prepareQuery(Page<EvalProcess> page, List<Filter> filters, List<Order> orders, HttpServletRequest    request) {
        evalProcessService.query(page, filters, orders);
    }
}
